<template>
	<view class="content">
		<button class="size" @tap="pick">从系统相册选择文件</button>
		<button class="size" @tap="pickMore">从相册中选择多张图片 </button>
		<button class="size" @tap="save">保存文件到系统相册中</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgUrl:""
			}
		},
		onLoad() {

		},
		methods: {
			pick(){
				// 从相册中选择图片
				console.log("从相册中选择图片:");
				plus.gallery.pick(function(path) {
					console.log("path=>",path);
					this.imgUrl = path;
				}, function(e) {
					console.log("取消选择图片");
				}, {
					filter: "image"
				});
			},
			pickMore(){
				console.log("从相册中选择多张图片:");
				plus.gallery.pick(function(e) {
					for (var i in e.files) {
						console.log(e.files[i]);
					}
				}, function(e) {
					console.log("取消选择图片");
				}, {
					filter: "image",
					multiple: true
				});
			},
			save(){
				plus.gallery.save( "_doc/1651807216-origin-IMG_7168.PNG" , function () {
					console.log( "保存图片到相册成功" );
				},function(e){
					console.log( "fail=>",e );
				});
			},
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.size {
		margin: 30rpx 0;
	}
</style>
